$(function() {
	$('#vue_vm_list div').hide();
});

var cgIndiServiceSendOrder = {
	cgIndiServiceSendOrderId: '',
	caregiverId: '',
	caregiverName: '',
	elderId: '',
	elderName: '',
	indiServiceCostId: '',
	indiServiceName: '',
	indiServicePrice: '',
	updateTime: '',
	createTime: '',
	createId: getLoginedUser()? getLoginedUser().staffId: '',
	updateId: getLoginedUser()? getLoginedUser().staffId: '',
	status: '',
	subjectRoomId: getLoginedUser().subjectRoomId,
	subjectRoomName: getLoginedUser().subjectRoomName
};

var view = {
	data: cgIndiServiceSendOrder
};

var vue_vm = new Vue({
	el: '#vue_vm',
	data: view
});

function save() {
	view.data.caregiverId = $('input:radio[name="caregiverId"]:checked').val();
	view.data.caregiverName = $('input:radio[name="caregiverId"]:checked').attr('caregiverName');
	view.data.indiServiceName = $('#indiService_select option:selected').text();
	view.data.caregiverSendOrdersStandardId = $('input:radio[name="caregiverId"]:checked').attr('caregiverSendOrdersStandardId');
	view.data.orderStandardName = $('input:radio[name="caregiverId"]:checked').attr('orderStandardName');
	
	if(!view.data.caregiverId) {
		alert('请选择护理员');
		return;
	}
	
	view.data.subjectRoomId = getLoginedUser().subjectRoomId;
	view.data.subjectRoomName = getLoginedUser().subjectRoomName;
	view.data.indiServicePrice = (view.data.indiServicePrice==''? 0: parseFloat(view.data.indiServicePrice));
	view.data.status = (view.data.status==''? 0: parseInt(view.data.status));

	save_basic(path+'/cgIndiServiceSendOrder/save', {cgIndiServiceSendOrder:view.data}, function() {
		alert('保存成功');
	});
}

function loadCgIndiServiceSendOrderByCond() {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();
	
	var searchVal = $('#searchVal').val();
	find_basic_by_json(path+'/cgIndiServiceSendOrder/findCaregiverDetail', {searchVal: searchVal}, function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			}
		});
		
		$('#vue_vm_list div').show();
	});
}

function findAll() {
	if($('#vue_vm_list').length==0) {return;}
	$('#vue_vm_list div').hide();

	findAll_basic(path+'/cgIndiServiceSendOrder/findAll', function(response) {
		$('#vue_vm_list').html(gl_vue_vm_list_html);
		
		new Vue({
			el: '#vue_vm_list',
			data: {
				todos: response.data
			}
		});
		
		$('#vue_vm_list div').show();
	});
}

function deleteBatch() {
	deleteBatch_basic(path+'/cgIndiServiceSendOrder/deleteBatch');
}
